from django.conf.urls import url
from . import modelviewset_view, genericviewset_view, views, apiview_view, genericapiview_view, mixin_view, childmixin_view, viewset_view
from rest_framework.routers import SimpleRouter, DefaultRouter

urlpatterns = [
    # # 获取所有图书、保存图书
    # url(r'^books/$', views.BooksView.as_view()),
    # # 获取单一图书、更新图书、删除图书
    # url(r'^books/(?P<book_id>\d+)$', views.BookView.as_view()),

    # APIView
    # # 获取所有图书、保存图书
    # url(r'^books/$', apiview_view.BooksView.as_view()),
    # # 获取单一图书、更新图书、删除图书
    # url(r'^books/(?P<book_id>\d+)$', apiview_view.BookView.as_view()),

    # GenericapiView
    # # 获取所有图书、保存图书
    # url(r'^books/$', genericapiview_view.BooksView.as_view()),
    # # 获取单一图书、更新图书、删除图书
    # # url(r'^books/(?P<book_id>\d+)$', genericapiview_view.BookView.as_view()),
    # url(r'^books/(?P<pk>\d+)$', genericapiview_view.BookView.as_view()),

    # GenericapiView 五个拓展类
    # # 获取所有图书、保存图书
    # url(r'^books/$', mixin_view.BooksView.as_view()),
    # # 获取单一图书、更新图书、删除图书
    # url(r'^books/(?P<pk>\d+)$', mixin_view.BookView.as_view()),

    # GenericapiView 拓展类的两个子类
    # # 获取所有图书、保存图书
    # url(r'^books/$', childmixin_view.BooksView.as_view()),
    # # 获取单一图书、更新图书、删除图书
    # url(r'^books/(?P<pk>\d+)$', childmixin_view.BookView.as_view()),

    # ViewSet
    # # 获取所有图书、保存图书
    # url(r'^books/$', viewset_view.BooksView.as_view({'get': 'list'})),
    # # 获取单一图书、更新图书、删除图书
    # url(r'^books/(?P<pk>\d+)$', viewset_view.BookView.as_view({'put': 'update'})),
    # url(r'^books/(?P<pk>\d+)/lastdata/$', viewset_view.BookView.as_view({'get': 'lastdata'})),

    # # genericViewSet
    # # 获取所有图书、保存图书
    # url(r'^books/$', genericviewset_view.BooksView.as_view({'get': 'list'})),
    # # 获取单一图书、更新图书、删除图书
    # url(r'^books/(?P<pk>\d+)$', genericviewset_view.BookView.as_view({'put': 'update'})),
    # url(r'^books/(?P<pk>\d+)/lastdata/$', genericviewset_view.BookView.as_view({'get': 'lastdata'})),

    # # modelViewSet
    # # 获取所有图书、保存图书
    # url(r'^books/$', modelviewset_view.BooksView.as_view({'get': 'list'})),
    # # 获取单一图书、更新图书、删除图书
    # url(r'^books/(?P<pk>\d+)$', modelviewset_view.BookView.as_view({'put': 'update'})),
    # url(r'^books/(?P<pk>\d+)/lastdata/$', modelviewset_view.BookView.as_view({'get': 'lastdata'})),

]

router = DefaultRouter()  # 继承自SimpleRouter...多了好多路由..都是什么用？
router.register('books', modelviewset_view.BooksView, base_name='books')
print(router.urls)
urlpatterns += router.urls